{extend name="base"}
{block name="title"}用户消息中心{/block}
{block name="head"}{/block}
{block name="body"}
<body class="mainbody">
<form>
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
        <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>用户消息中心</span>
    </div>
    <!--/导航栏-->

    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"><i class="iconfont icon-more"></i></a>
                <div class="l-list">
                    <div class="menu-list">

                        <div class="rule-single-select">
                            <select name="mt" style="display:none">
                                <option value="0">===所有类型===</option>
                                {volist name="MessageType" id="val"}
                                <option value="{$key}"{eq name="mt" value="$key"} selected{/eq}>{$val}[{$key}]</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="rule-single-select">
                            <select name="ut" style="display:none">
                                <option value="0">===发布范围===</option>
                                {volist name="UserType" id="val"}
                                <option value="{$key}"{eq name="ut" value="$key"} selected{/eq}>[{$key}]{$val}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="rule-single-select">
                            <select name="IsPass" style="display:none">
                                <option value="-1">===是否启用===</option>
                                <option value="0"{eq name="IsPass" value="0"} selected{/eq}>[0]启用</option>
                                <option value="1"{eq name="IsPass" value="1"} selected{/eq}>[1]未启用</option>
                            </select>
                        </div>
                        <input type="text" class="input txt" autocomplete="off" name="search" value="{$search|default=''|htmlentities}" placeholder="MsgID/UserID/GameID/昵称" />
                        <a class="btn-search"><i class="iconfont icon-search"></i></a>
                    </div>
                </div>
                <!--<div class="r-list">-->
                    <!--<a class="input">添加用户消息公告</a>-->
                <!--</div>-->
            </div>
        </div>
    </div>
    <!--/工具栏-->

    <div class="table-container">
        <table border="0" cellspacing="0" cellpadding="0" class="border-table ltable">
            <thead>
            <tr>
                <th>#</th>
                <th>ID</th>
                <th>用户标识</th>
                <th>发布时间</th>
                <th>发布消息ID</th>
                <th>消息类型</th>
                <th>消息标题</th>
                <th>消息内容</th>
                <th>房卡数</th>
                <th>金币数</th>
                <th>积分数</th>
                <th>称谓等级</th>
                <th>是否已读</th>
                <th>已读时间</th>
                <th>发布范围</th>
                <th>是否启用</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {empty name="list"}
            <tr><td colspan="9">Oh~暂无数据!</td></tr>
            {else}
            {volist name="list" id="v"}
            <tr data-id="{$v.MsgID}" data-UserID="{$v.UserID}">
                <td>{$v.ROW_NUMBER}</td>
                <td>{$v.ID}</td>
                <td class="user-avatar">
                <a target="_blank" href="{:url('user.detail/index')}?UserID={$v.UserID}">
                    <img src="{$v.AccountImgUrl?:'__STATIC__/houtai/images/dface.png'}" />
                </a>
                <div class="user-box">
                    <h4><a target="_blank" class="at_{$v.AccountsType}" href="{:url('user.detail/index')}?UserID={$v.UserID}">{:htmlentities($v.NickName)}</a></h4>
                    <i>{$v.GameID}</i>
                </div>
                </td>
                <td>{$v.CreateDate}</td>
                <td>{$v.MsgID}</td>
                <td style="color:{gt name='v.MsgType' value='1'}red{else}green{/gt}">[{$v.MsgType}]{switch name="v.MsgType"}{case value="1"}通知{/case}{case value="2"}补偿{/case}{/switch}</td>
                <td style="white-space:normal; word-break: break-all;">{:htmlentities($v.MsgTitle)}</td>
                <td style="white-space:normal; word-break: break-all;">{:htmlentities($v.MsgContent)}</td>
                <td style="white-space:normal; word-break: break-all;">{$v.MRoomCard}</td>
                <td style="white-space:normal; word-break: break-all;">{$v.MGold}</td>
                <td style="white-space:normal; word-break: break-all;">{$v.MIntegral}</td>
                <td style="white-space:normal; word-break: break-all;">{eq name='v.MGameLogo' value='0'}---{else}{$v.MGameLogo}{/eq}</td>
                <td style="color:{eq name='v.IsRead' value='0'}red{else}green{/eq}">{eq name='v.IsRead' value='0'}未读{else}已读{/eq}</td>
                <td>{eq name='v.ReadDate' value='1900-01-01 00:00:00.000'}---{else}{$v.ReadDate}{/eq}</td>
                <td>[{$v.UserType}]{switch name="v.UserType"}{case value="1"}所有用户{/case}{case value="2"}代理用户{/case}{case value="3"}玩家用户{/case}{case value="4"}指定用户{/case}{/switch}</td>
                <td style="color:{gt name='v.IsPass' value='0'}red{else}green{/gt}" title="{$v.IsPass}">{gt name='v.IsPass' value='0'}禁用{else}启用{/gt}</td>
                <td>
                    <a class="input">修改</a><br/>
                    <a class="input">删除</a>
                </td>
            </tr>
            {/volist}
            {/empty}
            </tbody>
        </table>
    </div>

    <!--内容底部-->
    <div class="page-footer"><div class="btn-wrap">{$list->render()}</div></div>
    <!--/内容底部-->

</form>
<script>
    $.extend({
        SystemMsg: {
            ShowDetailDialog: function (id,UserID) {

                var url = "{:url('detail')}?id=" + id+"&UserID="+UserID;
                dialog($.extend({
                    title: '详情:[' + id + ']==用户UserID:['+UserID+']',
                    url: url,
                    width: 700,
                    height: 530,
                    okValue: '确认提交',
                    ok: function () {
                        var f = $('iframe', this.node);
                        var v = $('form', f.contents()).serialize();
                        console.log(f);
                        console.log(v);
                        $.post(url, v, function (resp, state, xhr) {
                            console.log(resp);
                            alert(resp.error);
                            if (resp.errno == 0) {
                                location.reload();
                            }
                        });
                        return false;
                    }
                }, id > 0 ? {
                    button: [{
                        value: '删除规则',
                        autofocus: true,
                        callback: function () {
                            $.SystemMsg.ShowDeleteConfirm(id);
                            return false;
                        }
                    }
                    ]
                } : {})).showModal();
            },
            ShowDeleteConfirm: function (id) {
                dialog({
                    title: '提示',
                    content: '确定删除?id=' + id,
                    width: 200,
                    height: 30,
                    okValue: '确认',
                    ok: function () {
                        var url = "{:url('delete')}?id=" + id;
                        $.post(url, function (resp, state, xhr) {
                            console.log(resp);
                            alert(resp.error);
                            if (resp.errno == 0) {
                                location.reload();
                            }
                        });
                        return false;
                    }
                }).showModal();
            }
        }
    });
    $(function () {
        $('.toolbar a.input').click(function () { // 新建
            $.SystemMsg.ShowDetailDialog(0);
        });
        $('table.ltable td:last-child a.input:nth-child(1)').click(function () {  // 修改
            var id = $(this).parents('tr').attr('data-id');
            var Userid = $(this).parents('tr').attr('data-UserID');
            $.SystemMsg.ShowDetailDialog(id,Userid);
        });
        $('table.ltable td:last-child a.input:nth-child(2)').click(function () {  // 删除
            var id = $(this).parents('tr').attr('data-id');
            $.SystemMsg.ShowDeleteConfirm(id);
        });
        $("#allUser").click(function(){
            dialog({
                title: '提示',
                content: '所有用户的消息暂时不能修改，只能先删除再增加',
                width: 200,
                height: 30,
                okValue: '确认',
                ok: function () {
                    location.reload();
                }
            }).showModal();;
        })
    });
</script>
</body>
{/block}